

module enum_type();
    enum { IDLE, START, STOP } state;
    typedef enum { RED, GREEN, BLUE, YELLOW, WHITE, BLACK } color_t;

    color_t color;

    initial begin
        state = IDLE;
        $display("state is: (%0d, %s)", state, state.name());

        color = GREEN;
        $display("color is: (%0d, %s)", color, color.name());

        color = color.first();
        $display("color.first(): (%0d, %s)", color, color.name());
        color = color.last();
        $display("color.last(): (%0d, %s)", color, color.name());

        color = color.prev(4);
        $display("color.prev(4): (%0d, %s)", color, color.name());
        color = color.next(2);
        $display("color.next(2): (%0d, %s)", color, color.name());

        $display("number of colors: %0d", color.num());
    end

endmodule
